<template>
  <div id="detail-navbar">
    <nav-bar>
      <img slot="left" class="back" @click="backClick" src="~assets/img/common/back.svg" alt="" />
      <div slot="center" class="title">
        <div v-for="(item, index) in titles" class="titleItem" :class="{ active: index === currentIndex }" @click="titleClick(index)">
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from 'components/common/navbar/NavBar.vue'
export default {
  name: 'DetailNavBar',
  components: {
    NavBar
  },
  props: {
    currentIndex: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      titles: ['商品', '参数', '评论', '推荐']
    }
  },
  created() {},
  methods: {
    titleClick(index) {
      this.$emit('titleClick', index)
    },
    backClick() {
      this.$router.back()
    }
  }
}
</script>

<style lang="less" scoped>
#detail-navbar {
  position: relative;
  z-index: 6;
  background-color: #fff;
  .back {
    margin-top: 12px;
  }
  .title {
    display: flex;
    font-size: 13px;
    .titleItem {
      flex: 1;
    }
    .active {
      color: var(--color-high-text);
    }
  }
}
</style>
